﻿@model List<AppSeguro.Models.Contatos>

@{
    ViewBag.Title = "Busca de Contatos";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using (Html.BeginForm("PesquisarContato", "Home", FormMethod.Get))
{
    <div class="form-group">
        <div>
            <input type="text" name="q" id="q" placeholder="Pesquisar..."/>
            @Html.AntiForgeryToken();
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-2">
            <button class="btn btn-primary" type="submit">Pesquisar</button>
            @Html.ActionLink("Voltar", "Index", null, new { @class = "btn btn-warning" })
        </div>
    </div>
}
<h3>Resultados da busca para: <i>@Request.Params["q"]</i></h3>

@if (Model.Count == 0)
{
    <h6>Sua busca não trouxe resultados.</h6>
}
else
{
    <div class="table-responsive">
        <table class="table table-bordered table-hover">
            <thead>
                <tr>
                    <th>Nome</th>
                    <th>Email</th>
                    <th>Telefone</th>
                    <th>Celular</th>
                    <th>Telefone Comercial</th>
                    <th>Ações</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr>
                        <td>@item.Nome</td>
                        <td>@item.Email</td>
                        <td>@item.Telefone</td>
                        <td>@item.Celular</td>
                        <td>@item.TelComercial</td>
                        <td>
                            <a class="btn btn-warning btn-sm" href="~/Home/AlteraContato/@item.Id" title="Alterar Contato">Alterar <span class="glyphicon glyphicon-edit"></span></a>
                            <a class="btn btn-danger btn-sm" href="~/Home/ExcluiContato/@item.Id" title="Excluir Contato">Excluir <span class="glyphicon glyphicon-remove-circle"></span></a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}
